#include <stdio.h>
#include <stdlib.h>

#include "dbg.h"
#include "list.h"
#include "stack.h"

int stack_push(Stack *stack, const void *data)
{
    return list_ins_next(stack, NULL, data);
}

int stack_pop(Stack *stack, void **data)
{
    return list_rem_next(stack, NULL, data);
}

int main(int argc, char *argv[])
{
    int *data;
    Stack *s = stack_init(NULL, NULL);
    check_mem(s);

    data = (int *)malloc(sizeof(int));
    *data = 5;
    stack_push(s, data);
    data = (int *)malloc(sizeof(int));
    *data = 4;
    stack_push(s, data);
    stack_pop(s, (void **)&data);
    stack_destroy(s);

    return 0;
error:
    stack_destroy(s);
    return -1;
}
